﻿<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>凉山州中考信息管理系统</title>
<link rel="stylesheet" href="/css/newStyle.css"
	th:href="@{/css/newStyle.css}">
</head>
<style type="text/css">
/* 选中按钮的样式 */
.selectedBtn {
	opacity: 0.5;
}
</style>
<body>
<!-- 返回上一级提交表单 -->
<form id="returnBack" action="check" method="post">
	<input type="hidden" th:value="${junior.byzxdm}" name="byzxdm" />
	<input type="hidden" th:value="${junior.byzxmc}" name="byzxmc" />
	<input type="hidden" th:value="${junior.password}" name="password" />
</form>
	<!-- 修改学生表单提交 -->
	<form id="updateStuForm" action="updateStudents" method="post"></form>
	<div class="mainBox container">
		<div class="mainBox_inner" th:object="${junior}">
			<h1>凉山州中考信息管理系统(初中毕业学校)</h1>
			<form action="" method="post" id="form1">
				<input id="param_bmh" type="hidden" name="bmh" value="">
				<input id="param_sfzh" type="hidden" name="sfzh" value=""> <input
					id="param_sele" type="hidden" name="sele" value="">
					<!-- 
					<div class="row">
						<div class="input-group">
							<span class="input-group-addon"
								style="color: rgb(0, 91, 171); font-size: 14px">本地学生</span> <input
								type="text" class="form-control" placeholder="姓名或身份证号部分字符" id="sfzh_bd"/>

						</div>
						<div class="clearfix" style="margin-bottom: 10px;"></div>
						<button type="button" class="btn center-block" id="search1"
							name="search1">查询</button>
					</div>
					 -->
					
				<div class="tableOutBox">
					<div class="fl" ><h4><span th:text="${junior.byzxmc}+' 报名信息管理'">报名信息管理</span></h4></div>
					<div class="fr rightbox" >
						<button id="back" type="button" class="loginOut" onclick="$('#returnBack').submit();">[返回上级]</button>
						<button id="SignUped" type="button" class="loginOut" onclick="is_submit(2)">[已报名学生]</button>
                          <button id="UnsignUped" type="button" class="loginOut" onclick="is_submit(3)">[未报名学生]</button>
                        <button id="update" class="loginOut" type="button" onclick="updateStudent()" >[修改学生信息]</button>
                          <button id="resetpwd" class="loginOut" type="button" onclick="is_submit(6)">[重置学生密码]</button>
                          <button id="takephoto" class="loginOut" type="button" onclick="is_submit(7)">[拍照]</button>
                          <button id="Logout" type="button" class="loginOut" onclick="is_submit(1)">[退出]</button>
					      
                          
						</div>
												<div class="clearfix exportOutbox"></div>
												 
						<div class="row">
						<hr style=" height:2px;border:none;border-top:2px solid #185598;" />
						</div>
						<div class="row text-right">
						<span th:text="${status}">密码修改结果</span></div>
				</div>
				<div class="toolsbar">
				<div class="tableSearch clearfix">
     					<div class="fl">
	   					<div class="fl searchOut">
							<input id="search_sfzh" type="text" placeholder="输入学生身份证号" class="searchtext"  name="search_sfzh" value="">
							<button class="searchbtn"></button>
						</div>
					</div>
				</div>
				</div>
<div class="tablebox" th:object="${students}">
	<table id="shenhetable"> 
	</table>
 <div class="clearfix exportOutbox"></div>
</div>
			</form>
			</div>
		</div>
</body>
<script src="js/jquery-3.2.1.min.js"></script>
<script src="js/gVerify.js"></script>
<script src="js/commen.js"></script>
<link href="css/bootstrap.css" rel="stylesheet" />
<script src="../junior/js/bootstrap.js"></script>
<script src="../junior/js/bootstrap-table.js"></script>
<script src="../junior/js/bootstrap-editable.min.js"></script>
<script src="../junior/js/bootstrap-table-editable.js"></script>
<link href="css/bootstrap-table.css" rel="stylesheet" />
<script src="js/bootstrap-table-zh-CN.js"></script>
<script type="text/javascript" src="js/tableExport.js"></script>
<script type="text/javascript" src="js/base64.js"></script>
<script type="text/javascript" src="js/bootstrap-table-export.js"></script>

<!-- <script src="js/wishmanager.js"></script> -->
<script th:inline="javascript">
function is_submit(value) {
    var form1 = $("#form1");
    if (value == 1) {          
        var id = $("#id").val();
        form1.action = "logout";
         $("#form1").attr("action",form1.action);
        form1.submit();
    }else if (value == 2) {
        form1.action = "doSelectSignUpStudentByByzxdm";
        $("#form1").attr("action", form1.action);
        form1.submit();
    }else if (value == 3) {
        form1.action = "doSelectNotSignUpStudentByByzxdm";
        $("#form1").attr("action", form1.action);
        form1.submit();
    }else if (value == 4) {
    	//返回上级页面
    	 //window.location.href = "junior/juniorselect.html";
    	//window.history.back(-1);
    	//window.navigate("juniorselect.html");
    	//self.location='juniorselect.html';
    	top.location='juniorselect.html';
    }else if (value == 5) {
        form1.action = "doSelectSignUpStudentByByzxdm";
        $("#form1").attr("action", form1.action);
        form1.submit();
    }else if (value == 6) {
    	arr = $("#shenhetable").bootstrapTable('getSelections');
        if (arr.length > 1) {
            alert('只能选择一个学生重置密码');
            return;
        }
        
        if (arr.length <= 0) {
            alert('请选择一个学生');
            return;}
        $("#param_sfzh").val($.trim(arr[0].sfzh));
        form1.action = "doInitPassword";
        $("#form1").attr("action", form1.action);
        form1.submit();
    }if (value == 7) {
        form1.action = "takePhoto";
        $("#form1").attr("action", form1.action);
        form1.submit();
    }
}


var st=[[${students}]];
	
$(function () {
    //1.初始化Table
    var arr;
    var oTable = new TableInit();
    oTable.Init();
	var href = location.href;
	var href = href.substring(href.lastIndexOf('/')+1);
		if(href  == "doSelectSignUpStudentByByzxdm"){
			$("#SignUped").addClass("selectedBtn");
		}else if(href  == "doSelectNotSignUpStudentByByzxdm"){
			$("#UnsignUped").addClass("selectedBtn");
		}
		
})
	//全选
	$('.checkall').on(
			'change',
			function() {
				console.log($(this).is(':checked'))
				var checkstate = $(this).is(':checked');
				if (checkstate == true) {
					//全选
					$('tbody tr').find('input[type=checkbox].chose').prop(
							'checked', true);
				} else {
					//取消全选
					$('tbody tr').find('input[type=checkbox].chose').prop(
							'checked', false);
				}
			})


	$("#wishedandnowish").change(function() {
		var sele = $("#wishedandnowish").children('option:selected').val();
		//alert(bmh);
		form1.action = "doSelectStudentWishByConditionMiddle";
		//js代码  赋值
		document.getElementById('param_sele').value = sele;
		$("#form1").attr("action", form1.action);
		form1.submit();
	})

	$(".searchbtn").click(function() {
		 //$("#param_sfzh").val($.trim(arr[0].sfzh));
		//$("#param_sfzh").value = $("#search_sfzh").val();
		form1.action = "doSelectSignUpStudentByByzxdmAndSfzh";
		//js代码  赋值
		$("#form1").attr("action", form1.action);
		form1.submit();
	})



var TableInit = function () {
    var oTableInit = new Object();
    oTableInit.Destory = function () {
        $('#shenhetable').bootstrapTable('destroy');
    };
    oTableInit.Init = function () {
        $("#shenhetable").bootstrapTable({
            url: "",         //请求后台的URL（*）
            contentType: "application/x-www-form-urlencoded",
            method: 'post',                      //请求方式（*）
            toolbar: '#toolsbar',                //工具按钮用哪个容器
            striped: true,                      //是否显示行间隔色
            dataField:'studentstr',
            cache: true,                       //是否使用缓存，默认为true，所以一般情况下需要设置一下这个属性（*）
            pagination: true,                   //是否显示分页（*）
            silent: true,
            sortable: true,                     //是否启用排序
            sortOrder: "asc",                   //排序方式
            queryParams: oTableInit.queryParams,//传递参数（*）
            queryParamsType: "undefined",
            sidePagination: "client",           //分页方式：client客户端分页，server服务端分页（*）
            pageNumber: 1,                       //初始化加载第一页，默认第一页
            pageSize: 10,                       //每页的记录行数（*）
            pageList: [10, 25, 50, 100],        //可供选择的每页的行数（*）
            search: false,                       //是否显示表格搜索，此搜索是客户端搜索，不会进服务端，所以，个人感觉意义不大
            strictSearch: false,
            showColumns: true,                  //是否显示所有的列
            showRefresh: false,                  //是否显示刷新按钮
            minimumCountColumns: 2,             //最少允许的列数
            clickToSelect: true,                //是否启用点击选中行
            /* height: 500, */                        //行高，如果没有设置height属性，表格自动根据记录条数觉得表格高度
            uniqueId: "ID",                     //每一行的唯一标识，一般为主键列
            showToggle: false,                    //是否显示详细视图和列表视图的切换按钮
            cardView: false,                    //是否显示详细视图
            detailView: false,                   //是否显示父子表
            showExport: true, 
            exportTypes:['excel'],
            exportDataType: 'all',
            exportOptions:{  
                //ignoreColumn: [0],  //忽略某一列的索引  
                fileName: '报名表',  //文件名称设置  
                worksheetName: 'sheet1',  //表格工作区名称  
                tableName: '报名表',  
            }, 
            columns: [{
                field: 'chose',
                checkbox: true
            },
            {
            	field: 'id',
            	title: 'ID',
            	align: 'center'},
            {
            	field: 'xm',	
            	title: '姓名', 
            	align: 'center'},
            {
                field: 'bmh',
                title: '报名号'
                , align: 'center'
            },
            {
                field: 'sfzh',
                title: '身份证号'
                , align: 'center'
            },
            {
                field: 'mz',
                title: '民族'
                , align: 'center',formatter:function(value,row,inedex){
                	var nations = [{"code":"01","value":"汉族"},{"code":"07","value":"彝族"},{"code":"04","value":"藏族"},{"code":"20","value":"傈僳族"},{"code":"21","value":"佤族"},{"code":"05","value":"维吾尔族"},{"code":"22","value":"畲族"},{"code":"46","value":"德昂族"},{"code":"47","value":"保安族"},{"code":"06","value":"苗族"},{"code":"23","value":"高山族"},{"code":"08","value":"壮族"},{"code":"09","value":"布依族"},{"code":"02","value":"蒙古族"},{"code":"03","value":"回族"},{"code":"10","value":"朝鲜族"},{"code":"11","value":"满族"},{"code":"12","value":"侗族"},{"code":"13","value":"瑶族"},{"code":"14","value":"白族"},{"code":"15","value":"土家族"},{"code":"16","value":"哈尼族"},{"code":"17","value":"哈萨克族"},{"code":"18","value":"傣族"},{"code":"19","value":"黎族"},{"code":"24","value":"拉祜族"},{"code":"25","value":"水族"},{"code":"26","value":"东乡族"},{"code":"27","value":"纳西族"},{"code":"28","value":"景颇族"},{"code":"29","value":"柯尔克孜族"},{"code":"30","value":"土族"},{"code":"31","value":"达斡尔族"},{"code":"32","value":"仫佬族"},{"code":"33","value":"羌族"},{"code":"34","value":"布朗族"},{"code":"35","value":"撒拉族"},{"code":"36","value":"毛难族"},{"code":"37","value":"仡佬族"},{"code":"38","value":"锡伯族"},{"code":"39","value":"阿昌族"},{"code":"40","value":"普米族"},{"code":"41","value":"塔吉克族"},{"code":"42","value":"怒族"},{"code":"43","value":"乌孜别克族"},{"code":"44","value":"俄罗斯族"},{"code":"45","value":"鄂温克族"},{"code":"48","value":"裕固族"},{"code":"49","value":"京族"},{"code":"50","value":"塔塔尔族"},{"code":"51","value":"独龙族"},{"code":"52","value":"鄂伦春族"},{"code":"53","value":"赫哲族"},{"code":"54","value":"门巴族"},{"code":"55","value":"珞巴族"},{"code":"56","value":"基诺族"}];
					
                	for(var i=0;i<nations.length;i++){
                		if(nations[i].code == value){
                			return nations[i].value;
                		}
                	}
                	

					return value;
                }
            },   
            {
                field: 'csrq',
                title: '出生年月'
                , align: 'center'
            },
            {
                field: 'bjdm',
                title: '班级名称'
                , align: 'center'
            },
            {
                field: 'byzxdm',
                title: '毕业中学'
                , align: 'center'
            }, 
            {
                field: 'lxdh',
                title: '联系电话'
                , align: 'center'
            },          
            {
                field: 'kslb',
                title: '学生类别'
                , align: 'center',formatter:function(value,row,inedex){
					if("1" == value){
						return "初中应届";
					}else if("2" == value){
						return "初中往届";
					}
					return value;
                }
            }, 
            {
                field: 'xjh',
                title: '学籍号'
                , align: 'center'
            }, 
            {
                field: 'bynx',
                title: '毕业年份'
                , align: 'center'
            }, 
            {
                field: 'xb',
                title: '性别',
                align: 'center',
                formatter:function(value,row,inedex){
    					if("1" == value){
    						return "男";
    					}else if("2" == value){
    						return "女";
    					}
    					return value;
                    }
            }, 
            {
                field: 'zzmm',
                title: '政治面貌'
                , align: 'center',
                formatter:function(value,row,inedex){
					if("03" == value){
						return "团员";
					}else if("13" == value){
						return "非团员";
					}
					return value;
                }
            }, 
            {
                field: 'hklb',
                title: '户口类别'
                , align: 'center',
                formatter:function(value,row,inedex){
					if("1" == value){
						return "农村";
					}else if("2" == value){
						return "城市";
					}
					return value;
                }
            }, 
            {
                field: 'hjd',
                title: '户籍地'
                , align: 'center'
            }, 
            {
                field: 'yzbm',
                title: '邮政编码'
                , align: 'center'
            }, 
            {
                field: 'txdz',
                title: '通信地址'
                , align: 'center'
            }, 
             
            {
                field: 'js',
                title: '加试'
                , align: 'center',
                formatter:function(value,row,inedex){
					if("1" == value){
						return "藏文";
					}else if("2" == value){
						return "彝文";
					}else if("3" == value){
						return "无加试";
					}
					return value;
                }
            }, 
            {
                field: 'ddks',
                title: '考生模式'
                , align: 'center',
                formatter:function(value,row,inedex){
					if("2" == value){
						return "一类模式";
					}else if("3" == value){
						return "普通模式";
					}
					return value;
                }
            }, 
            {
                field: 'suiqian',
                title: '是否随迁 '
                , align: 'center'
            }
            
            ],
            data:st,
        });
    };
    oTableInit.queryParams = function (params) {
        var param = {
            bmh: $("searchtext").val(),
            pageSize: params.pageSize,   //页面大小
            pageIndex: params.pageNumber,  //页码
        };
        return param;
    };
    return oTableInit;
};

//获取后台数据
$("#search1").click(
		function() {
			var sfzh = $("#sfzh_bd").val();
			$.ajax({
				method : 'post',
				data : {
					"sfzh" : sfzh
				},
				url : 'doSelectSignUpInfoByCondition',
				success : function(result) {
					console.log(result);
					if (result != null && result != undefined) {
						var str = "";
						for (var i = 0; i < result.length; i++) {
							str += "<option data-isupdate='false' value="+result[i].sfzh+">"
									+ result[i].xm + "  " + result[i].sfzh +"</option>"
						}
						$("#left").html(str);
					}
				},
				error : function() {
					alert("xxxx!")
				}
			})
		});
	
/**
 * 修改学生信息
 */
function updateStudent(){
	//	只能修改已报名学生的信息
//	if(!$("#SignUped").hasClass("selectedBtn")){
//		alert("只能修改已报名学生的信息");return;
//	}
	var allSelected = $('#shenhetable').bootstrapTable('getAllSelections');
	if(!allSelected || allSelected.length==0){
		alert("请选择学生");return;
	}
	if(allSelected.length>1){
		alert("只能同时修改一个学生信息");return;
	}
	allSelected = allSelected[0];
	$("#updateStuForm").html('');
	var signUpStudent = new Object();
	signUpStudent.xm = "jonjian";
	  var keys = [];
       for (var key in allSelected) {
           if (allSelected.hasOwnProperty(key))
        	   keys.push(key);
       }
       var html = "";
       for(var i=0;i<keys.length;i++){
    	   var key = keys[i];
    	   var val = allSelected[key];
    	   val= val==null?"":val;
    	   html+="<input type='hidden' name='"+key+"' value='"+val+"' /> ";
       }
    $("#updateStuForm").append(html);
    $("#updateStuForm").submit();
}

</script>
</html>